#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Author: 钉钉或微信pythontesting 钉钉群21734177 技术支持qq群：630011153 144081101
# CreateDate: 2019-2-21

import collections
from bidict import bidict

from bazi.lib.ganzhi import *

nayins = {
    ('甲', '子'): '海中金', ('乙', '丑'): '海中金', ('壬', '寅'): '金泊金', ('癸', '卯'): '金泊金',
    ('庚', '辰'): '白蜡金', ('辛', '巳'): '白蜡金', ('甲', '午'): '砂中金', ('乙', '未'): '砂中金',
    ('壬', '申'): '剑锋金', ('癸', '酉'): '剑锋金', ('庚', '戌'): '钗钏金', ('辛', '亥'): '钗钏金',
    ('戊', '子'): '霹雳火', ('己', '丑'): '霹雳火', ('丙', '寅'): '炉中火', ('丁', '卯'): '炉中火',
    ('甲', '辰'): '覆灯火', ('乙', '巳'): '覆灯火', ('戊', '午'): '天上火', ('己', '未'): '天上火',
    ('丙', '申'): '山下火', ('丁', '酉'): '山下火', ('甲', '戌'): '山头火', ('乙', '亥'): '山头火',
    ('壬', '子'): '桑柘木', ('癸', '丑'): '桑柘木', ('庚', '寅'): '松柏木', ('辛', '卯'): '松柏木',
    ('戊', '辰'): '大林木', ('己', '巳'): '大林木', ('壬', '午'): '杨柳木', ('癸', '未'): '杨柳木',
    ('庚', '申'): '石榴木', ('辛', '酉'): '石榴木', ('戊', '戌'): '平地木', ('己', '亥'): '平地木',
    ('庚', '子'): '壁上土', ('辛', '丑'): '壁上土', ('戊', '寅'): '城头土', ('己', '卯'): '城头土',
    ('丙', '辰'): '砂中土', ('丁', '巳'): '砂中土', ('庚', '午'): '路旁土', ('辛', '未'): '路旁土',
    ('戊', '申'): '大驿土', ('己', '酉'): '大驿土', ('丙', '戌'): '屋上土', ('丁', '亥'): '屋上土',
    ('丙', '子'): '涧下水', ('丁', '丑'): '涧下水', ('甲', '寅'): '大溪水', ('乙', '卯'): '大溪水',
    ('壬', '辰'): '长流水', ('癸', '巳'): '长流水', ('丙', '午'): '天河水', ('丁', '未'): '天河水',
    ('甲', '申'): '井泉水', ('乙', '酉'): '井泉水', ('壬', '戌'): '大海水', ('癸', '亥'): '大海水',
}

empties = {
    ('甲', '子'): ('戌','亥'), ('乙', '丑'):('戌','亥'),
    ('丙', '寅'): ('戌','亥'), ('丁', '卯'): ('戌','亥'),
    ('戊', '辰'): ('戌','亥'), ('己', '巳'): ('戌','亥'),
    ('庚', '午'): ('戌','亥'), ('辛', '未'): ('戌','亥'),
    ('壬', '申'): ('戌','亥'), ('癸', '酉'): ('戌','亥'),

    ('甲', '戌'): ('申','酉'), ('乙', '亥'): ('申','酉'),
    ('丙', '子'): ('申','酉'), ('丁', '丑'): ('申','酉'),
    ('戊', '寅'): ('申','酉'), ('己', '卯'): ('申','酉'),
    ('庚', '辰'):('申','酉'), ('辛', '巳'): ('申','酉'),
    ('壬', '午'): ('申','酉'), ('癸', '未'): ('申','酉'),

    ('甲', '申'): ('午','未'), ('乙', '酉'): ('午','未'),
    ('丙', '戌'): ('午','未'), ('丁', '亥'): ('午','未'),
    ('戊', '子'): ('午','未'), ('己', '丑'): ('午','未'),
    ('庚', '寅'): ('午','未'), ('辛', '卯'): ('午','未'),
    ('壬', '辰'): ('午','未'), ('癸', '巳'): ('午','未'),

    ('甲', '午'): ('辰','己'), ('乙', '未'): ('辰','己'),
    ('丙', '申'): ('辰','己'), ('丁', '酉'): ('辰','己'),
    ('戊', '戌'): ('辰','己'), ('己', '亥'): ('辰','己'),
    ('庚', '子'): ('辰','己'), ('辛', '丑'): ('辰','己'),
    ('壬', '寅'): ('辰','己'), ('癸', '卯'): ('辰','己'),

    ('甲', '辰'): ('寅','卯'), ('乙', '巳'): ('寅','卯'),
    ('丙', '午'): ('寅','卯'), ('丁', '未'): ('寅','卯'),
    ('戊', '申'): ('寅','卯'), ('己', '酉'): ('寅','卯'),
    ('庚', '戌'): ('寅','卯'), ('辛', '亥'): ('寅','卯'),
    ('壬', '子'): ('寅','卯'), ('癸', '丑'): ('寅','卯'),


    ('甲', '寅'): ('子','丑 '), ('乙', '卯'): ('子','丑 '),
    ('丙', '辰'): ('子','丑 '), ('丁', '巳'): ('子','丑 '),
    ('戊', '午'): ('子','丑 '), ('己', '未'): ('子','丑 '),
    ('庚', '申'): ('子','丑 '), ('辛', '酉'): ('子','丑 '),
    ('壬', '戌'): ('子','丑 '), ('癸', '亥'): ('子','丑 '),
}


lu_types = {
    "甲":{('丙','寅'):'福星禄 名位禄 吉', ('戊','寅'):'伏马禄 吉',
           ('庚','寅'):'破禄，半吉半凶', ('壬','寅'):'正禄，带截路空亡，必为僧道 不吉',
           ('甲','寅'):'长生禄，大吉', ('乙','卯'):'生成禄，大吉',},
    "乙":{('乙','卯'):'喜神旺禄 吉', ('丁','卯'):'截路空亡 凶',
           ('己','卯'):'进神禄 吉', ('辛','卯'):'破禄，又为交神，半吉半凶',
           ('癸','卯'):'死禄 虽贵终贫 凶',},
    "丙":{('己','巳'):'九天库禄 吉', ('辛','巳'):'截路空亡 凶',
           ('乙','巳'):'旺马禄 吉', ('丁','巳'):'库禄 吉',
           ('癸','巳'):'伏贵神禄，半吉半凶',},
    "丁":{('庚','午'):'截路空亡 凶', ('壬','午'):'德合禄 吉',
           ('甲','午'):'进神禄 吉', ('丙','午'):'喜神禄，交羊刃，半吉',
           ('戊','午'):'伏羊刃 禄，多凶',},
    "戊":{('己','巳'):'九天库禄，吉', ('辛', '巳'):'截路空亡 凶',
           ('癸','巳'):'贵神禄，戊癸化合，有官位重 吉', ('乙','巳'):'驿马同乡禄 吉',
           ('戊','巳'):'旺库禄 吉',},
    "己":{('庚','午'):'截路空亡 凶', ('壬','午'):'死鬼禄 凶',
           ('甲','午'):'进神合禄 显达之象 吉', ('丙','午'):'喜神禄 半吉',
           ('戊','午'):'伏神羊刃禄，凶',},
    "庚":{('壬','申'):'大败禄 凶', ('甲', '申'):'截路空亡禄 凶',
           ('丙','申'):'大败禄，多成败 半吉', ('戊','申'):'伏马禄，多滞，若值福星，贵吉',
           ('庚','申'):'长生禄，大吉',},
    "辛":{('癸','酉'):'伏神禄，水火相犯，凶', ('乙','酉'):'破禄 成败 凶',
           ('丁','酉'):'空亡贵神禄 丁木受气，辛水沐浴，主奸淫事；值喜神，吉。',
           ('己','酉'):'进神禄 吉', ('辛','酉'):'正禄 吉',},
    "壬":{('丁','亥'):'贵神合禄 吉', ('乙', '亥'):'天德禄 吉',
           ('己','亥'):'旺禄 大吉', ('辛','亥'):'同马乡禄 大吉',
           ('癸','亥'):'大败禄，贫薄 凶',},
    "癸":{('甲','子'):'进神禄，主登科进达 吉', ('丙','子'):'交羊刃禄，带福星，贵有权。 吉',
           ('戊','子'):'伏羊刃合贵禄 半吉',
           ('庚','印禄'):'进神禄 吉', ('壬','子'):'正羊刃禄，凶',},
           }
tianyuans = [
    ("甲","巳"), ("甲","申"), ("甲","酉"), ("甲","丑"), ("甲","戌"),
    ("乙","巳"), ("乙","申"), ("乙","酉"), ("乙","丑"), ("乙","戌"),
    ("丙","亥"), ("丙","申"), ("丙","丑"), ("丙","辰"),  ("丙","子"),
    ("丁","亥"), ("丁","申"), ("丁","丑"), ("丁","辰"),  ("丙","子"),
    ("戊","寅"), ("戊","卯"), ("戊","未"), ("戊","亥"),  ("戊","戌"),
    ("己","寅"), ("己","卯"), ("己","未"), ("己","亥"),  ("己","戌"),
    ("庚","寅"), ("庚","未"), ("庚","戌"), ("庚","午"),  ("庚","巳"),
    ("辛","寅"), ("辛","未"), ("辛","戌"), ("辛","午"),  ("辛","巳"),
    ("壬","寅"), ("壬","辰"), ("壬","巳"), ("壬","申"),  ("壬","戌"), ("壬","丑"), ("壬","未"),  ("壬","午"),
    ("癸","寅"), ("癸","辰"), ("癸","巳"), ("癸","申"),  ("癸","戌"), ("癸","丑"), ("癸","未"),  ("癸","午"),
]


wenchang = {"甲":'巳', "乙":"亥", "丙":"戌", "丁":"辰", "戊":"申", "己":"午",
       "庚": "寅", "辛":"未", "壬": "卯", "癸":"丑"}
wenxing = {"甲":'午', "乙":"巳", "丙":"申", "丁":"酉", "戊":"申", "己":"酉",
            "庚": "戌", "辛":"亥", "壬": "寅", "癸":"卯"}
tianyin =  {"甲":'寅',  "乙":"亥", "丙":"戌", "丁":"酉", "戊":"申", "己":"未",
       "庚": "午", "辛":"巳", "壬": "辰", "癸":"卯"}
